package pe.gob.mintra.agrario.daoimpl;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;

import pe.gob.mintra.agrario.bean.Vacacion;
import pe.gob.mintra.agrario.dao.VacacionDAO;
import pe.gob.mintra.agrario.factory.MyBatisConnectionFactory;

public class VacacionDAOImp implements VacacionDAO {
	
	private final static Logger logVacacionDAOImp = Logger.getLogger(VacacionDAOImp.class);
	
	private SqlSessionFactory sqlSessionFactory;

	public VacacionDAOImp() {
		sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory();
	}
	

	@Override
	public void insertarVacacion(Vacacion objVacacion){
		
		SqlSession session = sqlSessionFactory.openSession();

		try {
			
			session.insert("Vacacion.insertarVacacion",objVacacion);
			session.commit();
		} 
		catch(Exception ex){
			session.rollback();
			logVacacionDAOImp.error(ex.getMessage());
		}
		finally {
			session.close();
		}

	}

}
